package com.shengyijie.activity.tab.user;
  

import com.shengyijie.activity.MainActivity;
import com.shengyijie.activity.R;     
import com.shengyijie.activity.share.ShareSelectActivity;  
import com.shengyijie.context.Commen;
import com.shengyijie.context.ContextApplication; 

import android.app.Activity;  
import android.content.Intent; 
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;  
import android.widget.Button; 
import android.widget.ImageButton;  
import android.widget.TextView;  

public class GBDetailActivity extends Activity implements OnClickListener{
       
	 
	
	 private ImageButton tabHome;
	 private ImageButton tabCategory;
	 private ImageButton tabRecommended;
	 private ImageButton tabUser;
	 private ImageButton tabMore;
	 
	 private TextView tv_id;
	 private TextView tv_pname;
	 private TextView tv_status; 
	 private TextView tv_time;
	 private TextView tv_name;
	 private TextView tv_tel; 
	 private TextView tv_email;
	 private TextView tv_add;
	 private TextView tv_content; 
	  
	  
	 
	
    public void onCreate(Bundle savedInstanceState){
         super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
         setContentView(R.layout.gbdetail);
         getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,      // 注意顺序
                 R.layout.title);
         initView(); 
         setItemInfo();
         Commen.setGuestBook(ContextApplication.user.getSession_ID(), ContextApplication.guesstBook.getId());
    }
     
    public void initView(){
    	TextView title=(TextView) this.findViewById(R.id.title);
		title.setText("详细留言"); 
		
		Button back=(Button) this.findViewById(R.id.back);
		back.setVisibility(View.VISIBLE);
		back.setOnClickListener(this);
//		
//		Button share=(Button) this.findViewById(R.id.right);
//		share.setVisibility(View.VISIBLE);
//		share.setOnClickListener(this);
		 
		
		tv_id=(TextView) this.findViewById(R.id.id);
		tv_pname=(TextView) this.findViewById(R.id.pname);
		tv_status=(TextView) this.findViewById(R.id.status);
		tv_time=(TextView) this.findViewById(R.id.time);
		tv_content=(TextView) this.findViewById(R.id.content);
		tv_tel=(TextView) this.findViewById(R.id.tel);
		tv_name=(TextView) this.findViewById(R.id.name);
		tv_email=(TextView) this.findViewById(R.id.email);
		tv_add=(TextView) this.findViewById(R.id.address);
		  
		  
    	tabHome=(ImageButton) this.findViewById(R.id.home);
    	tabCategory=(ImageButton) this.findViewById(R.id.category);
    	tabRecommended=(ImageButton) this.findViewById(R.id.recommended);
    	tabUser=(ImageButton) this.findViewById(R.id.user);
    	tabMore=(ImageButton) this.findViewById(R.id.more);
		try{
		    switch(ContextApplication.prePage){
		       case ContextApplication.PAGE_HOME:
		    	   tabHome.setSelected(true);
			       break;
		       case ContextApplication.PAGE_CATEGORY:
		    	   tabCategory.setSelected(true);
			       break;
		       case ContextApplication.PAGE_RECOMMENDED:
		    	   tabRecommended.setSelected(true);
			       break;
		       case ContextApplication.PAGE_USER:
		    	   tabUser.setSelected(true);
			       break;
		       case ContextApplication.PAGE_MORE:
		    	   tabMore.setSelected(true);
			       break;
		     }
		 }catch(Exception e){}
		
		 tabHome.setOnClickListener(this);
		 tabCategory.setOnClickListener(this);
		 tabRecommended.setOnClickListener(this);
		 tabUser.setOnClickListener(this);
		 tabMore.setOnClickListener(this);
		  
    }
    
    public void setItemInfo(){
    	try{
    		if(ContextApplication.guesstBook!=null){
    			tv_id.setText(ContextApplication.guesstBook.getId()+"");
    			
    			tv_status.setText("已读"); 
    			
    			tv_time.setText(ContextApplication.guesstBook.getTime());
    			tv_name.setText(ContextApplication.guesstBook.getName());
    			tv_tel.setText(ContextApplication.guesstBook.getMobile());
    			
    			tv_email.setText(ContextApplication.guesstBook.getEmail());
    			tv_add.setText(ContextApplication.guesstBook.getAddress());
    			tv_content.setText(ContextApplication.guesstBook.getContent());
    			tv_pname.setText(ContextApplication.project.getPro_name()); 
        	}
    	}catch(Exception e){}
    	
    	
    }
    
    
    
 

	@Override
	public void onClick(View v) { 
		Bundle bd = new Bundle();
        bd.putString("state", "exit");	
        Intent it = new Intent();
        it.putExtras(bd);
		switch(v.getId()){
		     case R.id.home:
			    try{
				   if(ContextApplication.prePage!=ContextApplication.PAGE_HOME){
					   MainActivity.tabhost.setCurrentTab(0);
					   setResult(RESULT_OK, it); 
					   this.finish();
				   }
			    }catch(Exception e){}
			    break;
		     case R.id.category:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_CATEGORY){
						   MainActivity.tabhost.setCurrentTab(1);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.recommended:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_RECOMMENDED){
						   MainActivity.tabhost.setCurrentTab(2);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.user:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_USER){
						   MainActivity.tabhost.setCurrentTab(3);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.more:
				    try{
					   if(ContextApplication.prePage!=ContextApplication.PAGE_MORE){
						   MainActivity.tabhost.setCurrentTab(4);
						   setResult(RESULT_OK, it); 
						   this.finish();
					   }
				    }catch(Exception e){}
				    break;
		     case R.id.right:
				    try{
				    	ContextApplication.shareName=ContextApplication.pushMessage.getTitle();
				    	ContextApplication.shareUrl=ContextApplication.pushMessage.getPro_url();
				    	if(ContextApplication.shareUrl==null||ContextApplication.shareUrl.equals("")){
				    		ContextApplication.shareUrl="http://www.shengyijie.net";
				    	}
				    	ContextApplication.shareContent="我在生意街商机网发现了“"+ContextApplication.shareName+
								 "”,觉得很不错，分享给大家...\n"+ContextApplication.shareUrl;
				    	Intent i=new Intent();
						i.setClass(this, ShareSelectActivity.class);
						this.startActivity(i);
				    }catch(Exception e){}
				    break;
		     case R.id.back:
				    try{
					  this.finish();
				    }catch(Exception e){}
				    break;
		      
		}
	}
	
   
	 
    
}